<template>
  <div class="score-item" :style="{ width }">
    <div class="score-item_title clearfix">
      <span class="iconfont" :class="icon" :style="{backgroundColor: iconBg}" />
      <span class="score-item_label">{{ title }}</span>
    </div>
    <div v-if="!contentSlot" class="score-item_num" :style="{color: color || '#fff'}">{{ activeNum || 0 }}</div>
    <div v-else class="score-item_num">
      <slot name="contentSlot" />
    </div>
  </div>
</template>

<script>
export default {
  name: 'ScoreItems',
  components: {},
  props: {
    width: { // 当前宽度
      type: String,
      default: '100%'
    },
    activeNum: { // 当前分数
      type: [String, Number],
      default: ''
    },
    title: { // 当前模块标题
      type: String,
      default: '100%'
    },
    contentSlot: { // 是否为自定义内容
      type: Boolean,
      default: false
    },
    icon: { // 当前图标（iconfont类型的图标）
      type: String,
      default: ''
    },
    iconBg: { // 当前图标背景色
      type: String,
      default: '#74BBC9'
    },
    color: { // 文字颜色
      type: String,
      default: '#67c23a'
    }
  },
  data() {
    return {}
  },
  computed: {},
  watch: {},
  created() {
  },
  mounted() {
  },
  methods: {}
}
</script>

<style scoped lang='scss'>

.score-item {
  color: #fff;
  background: rgba(0,0,0,.4);
  animation-name: example;
  animation-duration: 3s;
  border-radius: 8px;
  /*margin: 6px;*/
  margin-right: 2%;
  &:last-of-type{
    margin-right: 0;
  }
  padding: 14px 5px;

  &_title {
    margin-bottom: 12px;
    text-align: center;
    color: #fff;
  }
  @keyframes example {
    from {background-color: rgba(#e7a604, .4);}
    to {background-color: rgba(#90c72a, .4);}
  }
  &:hover {
    background-color: rgba(#48aabd, .4) !important;
    color: #fff;
  }
  .iconfont {
    display: inline-block;
    width: 23px;
    height: 23px;
    color: inherit;
    text-align: center;
    line-height: 23px;
    background: #74BBC9;
    border-radius: 50%;
    vertical-align: middle;
    float: left;
    margin-left: 5%;
  }
  &_label {
    font-size: 14px;
    font-weight: 400;
    color: inherit;
    vertical-align: middle;
    margin-left: 6px;
    display: inline-block;
    float: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    text-align: left;
    width: calc( 100% - 40px );
    line-height: 24px;
  }
  &_num {
    padding-left: 33px;
    font-size: 24px;
    font-weight: 500;
    color: inherit;
    text-align: center;
  }
}
</style>
